import java.io.*;
import java.util.*;
public class Main implements Serializable{
	private static final long serialVersionUID = 1L;
	String number;
	String name;
	double math;
	double English;
	double java;
	public Main(String x,String y,double z,double m,double n)
	{
		number=x;
		name=y;
		math=z;
		English=m;
		java=n;
	}
	public static void main(String[] args) {
		int i=0;
		double sum=0;
		Main [] t=new Main[2];
		List<Main> a=new ArrayList<Main>();
		a.add(new Main("01","张三",12,13,14));
		a.add(new Main("02","李四",15,16,17));
		try {
			ObjectOutputStream b=new ObjectOutputStream(new FileOutputStream("D:\\list.txt"));
			b.writeObject(a);
			b.flush();
			b.close();
			ObjectInputStream c=new ObjectInputStream(new FileInputStream("D:\\list.txt"));
			ArrayList<?> s=null;
			s =(ArrayList<?>) c.readObject() ;
			c.close();
			for(i=0;i<2;i++)					
			{
				t[i]=(Main)s.get(i);
				System.out.println("第"+(i+1)+"位学生所有课程平均分为："+(t[i].math+t[i].English+t[i].java)/3.0);
			} 
		    for(i=0;i<2;i++)	
			    sum=sum+t[i].math;
			System.out.println("全部学生的数学平均分为："+sum/2);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}